package org.lboot.chat.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.lboot.chat.module.file.model.ChatFile;
import org.lboot.chat.module.file.params.WebFileParams;
import org.lboot.chat.module.file.service.ChatFileService;
import org.lboot.core.domain.ResponseDTO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author kindear
 * 文件管理
 */
@Slf4j
@RestController
@RequestMapping("openai")
@Api(tags = "OpenAI文件管理")
@AllArgsConstructor
public class ChatFileController {
    ChatFileService fileService;

    @GetMapping("files")
    @ApiOperation(value = "文件列表")
    public Object listFiles(){
        return fileService.listFiles();
    }


    @PostMapping("files")
    @ApiOperation(value = "上传文件")
    @SneakyThrows
    public ResponseDTO<ChatFile> uploadFile(WebFileParams params){
        return ResponseDTO.succData(fileService.uploadFile(params));
    }

}
